//
//  ZXZMyCustomViewController.m
//  sheyingzu
//
//  Created by tyu on 29.5.24.
//

#import "ZXZMyCustomViewController.h"

#import "ZXZMyCustomView.h"
#import "ZXZMyCustomAddViewController.h"


#import "ZXZNoDataView.h"

@interface ZXZMyCustomViewController ()

@property(nonatomic,weak) UIScrollView *ScrollView;

@property(nonatomic,weak) ZXZMyCustomView *goodsView1;

@property(nonatomic,weak) ZXZNoDataView *dataView;




@end

@implementation ZXZMyCustomViewController


- (void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:animated];
    [self updata];
}

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.

    self.view.backgroundColor = [UIView ColorWithHexString:@"#F8F9FB" alpha:1];

}


- (void)bac_addUI
{
    [super bac_addUI];
    [self setupView];
    self.bacTitleLabel.text = @"我的定制";
    [self.view bringSubviewToFront:self.navView];
    
    
    UIButton *phoneBtn = [[UIButton alloc] init];
    [self.navView addSubview:phoneBtn];
    [phoneBtn setTitle:@"添加定制" forState:UIControlStateNormal];
    [phoneBtn setTitleColor:[UIView ColorWithHexString:@"#333333"] forState:UIControlStateNormal];

    phoneBtn.frame = CGRectMake(ScreenWidth-100, 50, 80, 40);
    [phoneBtn addTarget:self action:@selector(phoneBtnClick) forControlEvents:UIControlEventTouchUpInside];
    
    
}
- (void)phoneBtnClick
{

    ZXZMyCustomAddViewController *vc = [ZXZMyCustomAddViewController new];
    [self.navigationController pushViewController:vc animated:YES];
    
}



- (void)setupView{
    
    UIScrollView *ScrollV = [[UIScrollView alloc]init];
    [self.view addSubview:ScrollV];
    self.ScrollView =ScrollV;

    ScrollV.contentSize = CGSizeMake(ScreenWidth, ScreenHeight*1.5);
    ScrollV.contentInset = UIEdgeInsetsMake(0, 0, -10, 0);
    ScrollV.showsVerticalScrollIndicator = NO;
    ScrollV.frame = CGRectMake(0, 100, ScreenWidth, ScreenHeight-ShowDiff);

    
    [self setListCell];

    ZXZNoDataView *dataView = [ZXZNoDataView new];
    [self.ScrollView addSubview:dataView];
    self.dataView = dataView;
    dataView.TitleLab.text  = @"暂无定制";
    dataView.frame = CGRectMake(0, 250, ScreenWidth, 150);
    
    
    
  
    
    
}

- (void)updata
{
    if ([[userDef valueForKey:@"dingzhi"] isEqualToString:@"1"]) {
        self.dataView.hidden = YES;
        self.goodsView1.hidden = NO;
        self.goodsView1.TitleLab.text = [userDef valueForKey:@"dingzhititle"];
        self.goodsView1.ImgV.image = [UIImage imageNamed:@"goods1"];
        self.goodsView1.SubLab.text = [NSString stringWithFormat:@"租期%@天",[userDef valueForKey:@"dingzhiday"]];

    }else{
      
        self.dataView.hidden = NO;
        self.goodsView1.hidden = YES;
    }
}


- (void)setListCell
{
    
    ZXZMyCustomView *goods = [[ZXZMyCustomView alloc]init];
    [self.ScrollView addSubview:goods];
    self.goodsView1 = goods;
    
    goods.ClcikBlock = ^(NSString * _Nonnull Str) {

            
    };
    goods.rightBtnBlock = ^(NSString * _Nonnull Str) {
            [userDef setValue:@"0" forKey:@"dingzhi"];
        self.dataView.hidden = NO;
        self.goodsView1.hidden = YES;
    };
  
    
    CGFloat height = 140;
    CGFloat width = (ScreenWidth-30);

    self.goodsView1.frame = CGRectMake(15,20, width, height);
    self.goodsView1.layer.cornerRadius = 10;
    self.goodsView1.layer.masksToBounds = YES;

}

    
/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
